package com.dm.wallpaper.library.ablility.slice;

import com.dm.wallpaper.library.ResourceTable;
import com.dm.wallpaper.library.fraction.CateoryWallpaperSearchFraction;
import com.dm.wallpaper.library.fraction.FractionHelper;
import com.dm.wallpaper.library.fraction.WallpaperBoardBrowserSearchFraction;
import com.dm.wallpaper.library.helpers.LocaleHelper;
import com.dm.wallpaper.library.preferences.Preferences;
import com.dm.wallpaper.library.utils.Extras;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.ability.fraction.FractionAbility;
import ohos.aafwk.content.Intent;

import java.util.Locale;
/*
 * Copyright (C) 2021 The Chinese Software International Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
public class WallpaperBoardBrowserAbilitySlice extends AbilitySlice {


    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_wallpaper_board_brower);
        Locale locale = Preferences.get().getCurrentLocale();
        LocaleHelper.setLocale(locale);
        int fragmentId = intent.getIntParam(Extras.EXTRA_FRAGMENT_ID, Extras.ID_WALLPAPER_SEARCH);
        if (fragmentId == Extras.ID_CATEGORY_WALLPAPERS) {
            FractionHelper.getInstance((FractionAbility) getAbility()).addFraction(ResourceTable.Id_search_layout, CateoryWallpaperSearchFraction.class);
            FractionHelper.getInstance((FractionAbility) getAbility()).showFraction(CateoryWallpaperSearchFraction.class);
        } else if (fragmentId == Extras.ID_WALLPAPER_SEARCH) {
            FractionHelper.getInstance((FractionAbility) getAbility()).addFraction(ResourceTable.Id_search_layout, WallpaperBoardBrowserSearchFraction.class);
            FractionHelper.getInstance((FractionAbility) getAbility()).showFraction(WallpaperBoardBrowserSearchFraction.class);
        }
    }


}
